#pragma once
#include"../event/Object.h"
#include"../jsonCpp/json.h"
#include"../gameLogic/TeamGroup.h"
#include<map>

class TeamController:public Object
{
public:
	TeamController(Object* master);
	virtual ~TeamController();

	void C2S_CreateTeam(Json::Value& message);
	void C2S_InviteTeam(Json::Value& message);
	void C2S_DelTeam(Json::Value& message);
	void C2S_QuitTeam(Json::Value& message);
	void C2S_OptInviteTeam(Json::Value& message);
	void C2S_TeamGroupEnterScene(Json::Value& message);

	int getUserTeamId(int userId);
	
	TeamGroup* getTeamGroup(int userId);

	TeamGroup* getTeamGroupByTeamId(int teamId);

	void removeUserId(int userId);
	
	void addTeam(const int& userId, const int& targetId);

	void checkTeam(const int& userId);
private:
	void notifyTeam(int teamId);

	Object* m_master;

	std::map<int, int> m_userMapTeam;
	std::map<int, TeamGroup> m_teamGroupMaps;
	
	static int global_teamId;
};
